package com.deli.springboot.utils;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;
import java.util.List;

/**
 * @Author: xudeli
 * @Description: json数据返回
 * @CreateDate: 2018/4/22 23:35
 **/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
public class JsonResponse<T> implements Serializable {

    private static final long serialVersionUID = -4704382707524257914L;

    //设置相应状态码
    private String code;

    //设置返回结果true and false

    private String result;

    //设置返回消息
    private String message;

    //设置返回的结果集
    private List<T> list;

    //设置返回的对象
    private T obj;

    //设置返回的结果数
    private Integer resNum;

    public JsonResponse() {
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }

    public Integer getResNum() {
        return resNum;
    }

    public void setResNum(Integer resNum) {
        this.resNum = resNum;
    }

    @Override
    public String toString() {
        return "JsonResponse{" +
                "code='" + code + '\'' +
                ", result='" + result + '\'' +
                ", message='" + message + '\'' +
                ", list=" + list +
                ", obj=" + obj +
                ", resNum=" + resNum +
                '}';
    }
}
